var container = document.querySelector('#content-container');
var containerWrapper = document.querySelector('.content-container-wrapper');
var progressJsInterval, progressFontInterval;

var progress = progressEvent();
var progressTerm = 0;
var time1;
var imgArray = [
];


function imgLoad(url, callback) {
  var img = new Image();
  img.src = url;
  if (img.complete) {
    if (typeof(callback) === 'function') callback();
  } else {
    img.onload = function() {
      if (typeof(callback) === 'function') callback();
    };
  }
}

function preImgLoad(array, index, callback) {
  if (index < array.length - 1) {
    imgLoad(array[index], preImgLoad(array, ++index, callback))
  } else if (index == array.length - 1) {
    imgLoad(array[index], callback)
  }
}

function loadJS(url, callback) {
  var script = document.createElement('script'),
    fn = callback || function() {};
  script.type = 'text/javascript';


  //IE
  if (script.readyState) {
    script.onreadystatechange = function() {
      if (script.readyState == 'loaded' || script.readyState == 'complete') {
        script.onreadystatechange = null;
        fn();
      } else {
        progress.update({
          title: '资源加载失败',
          progress: 80,
          max: 100
        })
      }
    };
  } else {
    //其他浏览器
    script.onload = function() {
      fn();
    };
    script.onerror = function() {
      progressJsInterval && clearInterval(progressJsInterval);
      progress.update({
        title: '资源加载失败',
        progress: 80,
        max: 100
      })
    }
  }
  script.src = url;
  document.getElementsByTagName('head')[0].appendChild(script);
}
//let date = +new Date();
let date = 1.0;



function loadResouceJs() {
  //脚本加载进度条
  progressJsInterval = setInterval(function() {
    if (progressTerm > 99) {
      clearInterval(progressJsInterval);
      first = 2
      progress.hide();
      $('#dialogBg1').hide();
      containerWrapper.style.visibility = 'visible'
      return
    }
    var dot = '....'.substring(0, progressTerm % 4);
    progressTerm = progressTerm + 10
    progress.update({
      title: '资源正在加载中' + dot,
      progress: progressTerm,
      max: 100
    })
  }, 1000);

}


loadResouceJs()

/*
var progress = progressEvent();
progress.update({title: '资源正在加载中', progress: 0, max: 100})
var progressTerm = 9;
var progressInterval = setInterval(function () {
  if (progressTerm > 48) {
    clearInterval(progressInterval);
    return
  }
  var dot = '....'.substring(0, progressTerm % 4);
  progress.update({title: '资源正在加载中' + dot, progress: progressTerm++, max: 100})
}, 1000);*/
